#ifndef S5P4418_GPIO_H_INCLUDED
#define S5P4418_GPIO_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>

#undef PAGE_SIZE
#undef PAGE_MASK

#define APP_NAME "gpio_ctrl"
#define VERSION "1.0"
#define BUILD_DATE __DATE__

#define PAGE_SHIFT		12
#define PAGE_SIZE  		(1<<PAGE_SHIFT)		/* 4096byte Per Mapped Memory page */
#define PAGE_MASK 		(~(PAGE_SIZE-1) )

#define GPIO_StartAddr	0xC001A000
#define GPIO_EndAddr	0xC001F000

#define REG(Addr)	(*(volatile unsigned int*) (Addr))

#define ERR_FILEERR -1
#define ERR_FMAPERR -2
#define ERR_GMAPERR -3

#define BLANK_GPA 0x0
#define BLANK_GPB 0x1000
#define BLANK_GPC 0x1000*2
#define BLANK_GPD 0x1000*3
#define BLANK_GPE 0x1000*4

#define TYPE_OUT 0x01
#define TYPE_IN 0X00
#define TYPE_SPECIAL 0x02
#define TYPE_RESERVED 0x03

#define STATUS_LOW 0
#define STATUS_HIGH 1

extern int gpio_init(); // 初始化
extern void gpio_exit(); // 销毁
extern void gpio_ioctl(unsigned int blank, int num, int type); // 设置GPIO模式
extern unsigned int gpio_read(unsigned int blank, int num); // 获取GPIO状态
extern void gpio_write(unsigned int blank, int num, int status); //设置GPIO状态
extern unsigned int gpio_readctl(unsigned int blank, int num);
#endif // S5P4418_GPIO_H_INCLUDED
